//
// Created by v on 2025/11/18.
//

#ifndef JKLIBS_CMSTORAGEBASE_H
#define JKLIBS_CMSTORAGEBASE_H

#include "avstorage.h"
#include "CMStorageManager.h"

class CMStorageBase
{
public:
    CMStorageBase(CMStorageManager *manager);
    virtual ~CMStorageBase();

    int savePath(const char *path);
    int saveStrategy(int s);
    int timePerFile(uint64_t time);
    int sizePerFile(uint64_t size);
    int storageLimitAsFree(size_t free_limit);
    int ext_name(const char *ext);

    int init();
    int deinit();

    int pushData(unsigned char *data, size_t size, const char *ext);

protected:
    std::string save_path;
    int save_strategy; // 0 - stop until full, 1 - delete oldest
    size_t time_per_file;
    size_t size_per_file;
    size_t storage_limit_as_free;
    std::string file_ext;

private:
    CMStorageManager *pri_manager;
    AVStorageP pri_storage;
};

#endif // JKLIBS_CMSTORAGEBASE_H
